package com.qf.util;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

/*
杨威
2021/9/18
8:33
*/
public class UploadUtil {
    public static String creatNewFileName(String fileName){
        String uuid = UUID.randomUUID().toString().replace("-", "");
        return uuid+"_"+fileName;
    }
    public static String creatNewFilePath(String filePath,String fileName){
        int i = fileName.hashCode();
        int i2=i&15;
        int i3=i>>4&15;
        return filePath+ File.separator+i2+File.separator+i3;
    }
    public static boolean check(String fileName){
        List list=new ArrayList();
        list.add(".jpg");
        list.add(".png");
        list.add(".bmp");
        list.add(".gif");
        list.add(".jpeg");
        String substring = fileName.substring(fileName.lastIndexOf("."));
        if(list.contains(substring)){
            return true;
        }else {
            return false;
        }

    }
}
